﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using SP_Form_Suggestion;

namespace SP_Form_Suggestion.Layouts.SP_Form_Suggestion
{
    public partial class FormSuggestionConfig : LayoutsPageBase
    {
        protected override void OnPreRender(EventArgs e)
        {

        }
        protected override void OnPreLoad(EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                SPContext ctx = SPContext.Current;
                SPWeb web = ctx.Web;
           
                    object jquery_Url = web.GetProperty(CONST.PROPERTY_BAG_JQUERY_URL);
                    Text_Jquery.Text = null != jquery_Url ? jquery_Url.ToString() : CONST.JQUERY_URL;


                    object jquery_Ui_Url = web.GetProperty(CONST.PROPERTY_BAG_JQUERY_UI_URL);
                    Text_JqueryUI.Text = null != jquery_Ui_Url ? jquery_Ui_Url.ToString() : CONST.JQUERY_UI_URL;

                    object jquery_UI_Css_Url = web.GetProperty(CONST.PROPERTY_BAG_JQUERY_UI_CSS_URL);
                    Text_JqueryUI_CSS.Text = null != jquery_UI_Css_Url ? jquery_UI_Css_Url.ToString() : CONST.JQUERY_UI_CSS_URL;

                


            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void submitClick(object sender, EventArgs e)
        {
            SPContext ctx = SPContext.Current;
            SPWeb web = ctx.Web;
            if (!web.UserIsWebAdmin)
                return;
            
            web.SetProperty(CONST.PROPERTY_BAG_JQUERY_URL, Text_Jquery.Text);
            web.SetProperty(CONST.PROPERTY_BAG_JQUERY_UI_URL, Text_JqueryUI.Text);
            web.SetProperty(CONST.PROPERTY_BAG_JQUERY_UI_CSS_URL, Text_JqueryUI_CSS.Text);
            web.Update();
        }
    }
    
}
